{include file="/public/header" /}
<div class="content-wraper full">
    <div class="tools-bar">
        <a data-key="add"><i class="fa fa-plus"></i> 添加</a>
        <a data-key="edit"><i class="fa fa-edit"></i> 编辑</a>
        <a data-key="delete"><i class="fa fa-trash"></i> 删除</a>
    </div>
    <div class="normal-line"></div>
    <div class="search_wraper" style="min-height: 51px;">
        <form class="normal_form search_form" onsubmit="return false;">
            <div class="condition" onscroll="Core.scrolling(this)">
            </div>
            <div class="row form-footer-bar">
                <button class="btn" type="reset" role="btn-cancel">重置</button>
                <button r-button class="btn btn-primary search-btn" type="submit" role="btn-submit">搜索</button>
                <button r-button style="display: none;" class="btn switch_search filter">展开搜索条件<i class="fa fa-angle-down"></i></button>
                <div style="margin: 10px 0 -10px;"><a class="search_close"><i class="fa fa-angle-up"></i>收起</a></div>
            </div>
        </form>
    </div>
    <div class="table_box">
        <table class="table_main" id="datalist"></table>
    </div>
</div>
<script type="text/javascript">
Core.Easyui.FieldColumn = [
    {field:'ck',checkbox:true,width:30},
	{field:'title',title:'名称',width:700,align:'center', search: true, nowsearch: true, searchtype: 'input',formatter:function(value,row,index){
		return value+(row.issys ? '<span style="color:red" title="系统关键角色,不可删除">[系统]</span>' : '');
	}},
	{field:'iorder',title:'排序',width:50,align:'center'},
];
Core.Easyui.init($("#datalist"), {
    url: "{$_G['_mc_']}/ajax",
    idField: "id",
    fitColumns: true,
    singleSelect : true,
    columns: [Core.Easyui.FieldColumn],
    pageSize: 50,
    onDblClickRow: function (index,row){
        Core.Sys.Action('pop',row);
    },
},$(".search_form"));

Core.Sys.Action = function(mkey,row){
    switch(mkey){
        case 'add':
            window.location.href = "{$_G['_mc_']}/edit";
        break;case 'edit':
            var row = $('#datalist').datagrid('getSelected');if (!row) return;
            Core.Sys.Action('pop',row);
        break;case 'pop':
            if (!row || !row.id) return;
            window.location.href = "{$_G['_mc_']}/edit/id/"+row.id;
        break;case 'delete':
            var row = $('#datalist').datagrid('getSelected');if (!row || row.issys) return;
            Core.Dialog.confirm({'title':'删除管理组','content':'确认要删除管理组吗？','ok':function(cbk){
                    $.get("{$_G['_mc_']}/delete/id/"+row.id+"?r="+Math.random(),function(data){
                        $('#datalist').datagrid('reload');
                    });
                    cbk();
                }
            });
        break;
    }
}
/**搜索 */
var Table_Filters = Core.Search.searchArray();
var filterType = Core.Search.typeList();
//var rsourceUrl = "/index.ajax/index"; //搜索字段基础数据
//var regionUrl = "/index.ajax/district/level/"; //城市搜索字段
Core.Search.initFilter(null, null);

$(document).ready(function(){
    $('.tools-bar a').click(function(){
        if (!Core.rule('key',$(this).attr('data-key'))) return false;
        Core.Sys.Action($(this).attr('data-key'));
    });
});
</script>
{include file="/public/footer" /}